from typing import List

from pydantic import BaseModel, Field


class Token(BaseModel):
    access_token: str
    token_type: str


class TokenData(BaseModel):
    mobile: str = None


class User(BaseModel):
    id: int = Field(None)
    mobile: str = Field(..., regex=r"^1[35678]\d{9}$")
    nickname: str = Field(..., max_length=12)
    avatar: str = Field(...)


class SendCaptchaVal(BaseModel):
    mobile: str = Field(..., regex=r"^1[35678]\d{9}$")


class CodeVal(BaseModel):
    code: str = Field(..., regex=r"\d{4}$")


class LoginVal(BaseModel):
    mobile: str = Field(..., regex=r"^1[35678]\d{9}$")
    captcha: str = Field(..., regex=r"\d{4}$")


class UpdateMobile(BaseModel):
    mobile: str = Field(..., regex=r"^1[35678]\d{9}$")
    captcha: str = Field(..., regex=r"\d{4}$")
    token: str = Field(...)


class UserInfo(BaseModel):
    nickname: str = Field(..., max_length=12)
    avatar: str = Field(...)
    gender: int = Field([0, 1, 2])
    birthday: str = Field(...)
    city: str = Field(..., max_length=8)
    cityName: str = Field(..., max_length=50)
    personalProfile: str = Field(..., max_length=160)


class Items(BaseModel):
    id: int = Field(...)
    name: str = Field(..., max_length=10)
    imageUrl: str = Field(...)
    isSelected: bool = Field(...)


class SaveInterestTags(BaseModel):
    name: str = Field(..., max_length=10)
    items: List[Items]


class CustomTag(BaseModel):
    tag: str = Field(..., max_length=10)


class Folder(BaseModel):
    """"""
    name: str = Field(..., max_length=40)
    description: str = Field(..., max_length=255)
    parentFolderId: int = Field(0)


class MediaExif(BaseModel):
    """"""
    key: str = Field(..., max_length=255)
    size: int = Field(...)
    type: str = Field(..., max_length=40)
    hash: str = Field(..., max_length=40)
    width: int = Field(...)
    height: int = Field(...)
    orientation: str = Field(..., max_length=255)
    color: str = Field(..., max_length=255)
    videoDuration: str = Field(..., max_length=15)
    videoWidth: int = Field(...)
    videoHeight: int = Field(...)
    videoRotate: str = Field(..., max_length=255)


class CreateMedia(BaseModel):
    """"""
    kind: str = Field(['photo'])
    medias: List[MediaExif] = Field(..., min_items=1)
    folderId: int = Field(...)


class MediaEdit(BaseModel):
    """"""
    title: str = Field('', max_length=255)
    customTags: List[str] = Field(...)


class Medias(BaseModel):
    """"""
    ids: List[int] = Field(..., min_items=1)
    folderId: int = Field(0)


class Recycles(BaseModel):
    """"""
    ids: List[int] = Field(..., min_items=1)
    folderId: int = Field(0)


class MoveMedias(BaseModel):
    """"""
    ids: List[int] = Field(..., min_items=1)
    fromFolderId: int = Field(...)
    toFolderId: int = Field(...)


class RemoveFolders(BaseModel):
    """"""
    ids: List[int] = Field(..., min_items=1)


class CreateComment(BaseModel):
    """"""
    commentId: int = Field(...)
    comment: str = Field(..., max_length=255)
